package com.chartboost.sdk;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.RelativeLayout;
import com.chartboost.sdk.Libraries.CBOrientation.Difference;
import com.chartboost.sdk.Libraries.a.a;
import com.chartboost.sdk.Libraries.e;
import com.chartboost.sdk.Libraries.e.b;
import com.chartboost.sdk.impl.a;
import com.chartboost.sdk.impl.a.b;
import com.chartboost.sdk.impl.s.a;
import org.json.JSONObject;

public abstract class b
{
  public a a = null;
  public c b = null;
  public a c = null;
  public a d = null;
  protected int e = 0;
  protected JSONObject f;
  protected a g;
  private int h;
  private int i;
  private int j;
  private b k;

  public b(a parama)
  {
    this.g = parama;
    this.k = null;
  }

  protected abstract b a(Context paramContext);

  protected void a(a.a parama)
  {
    if (parama != null)
      this.h = (1 + this.h);
    this.i = (1 + this.i);
    if ((this.i != this.e) || (a()));
    while (this.d == null)
      return;
    this.d.a();
  }

  protected void a(String paramString, e.b paramb)
  {
    a(paramString, paramb, false);
  }

  protected void a(String paramString, e.b paramb, boolean paramBoolean)
  {
    Bundle localBundle = new Bundle();
    localBundle.putBoolean("paramNoMemoryCache", paramBoolean);
    a(this.f, paramString, paramb, localBundle);
  }

  public void a(JSONObject paramJSONObject)
  {
    this.i = 0;
    this.j = 0;
    this.h = 0;
    this.f = paramJSONObject.optJSONObject("assets");
    if ((this.f == null) && (this.d != null))
      this.d.a();
  }

  protected void a(JSONObject paramJSONObject, String paramString, e.b paramb, Bundle paramBundle)
  {
    JSONObject localJSONObject = paramJSONObject.optJSONObject(paramString);
    if (localJSONObject != null)
    {
      this.j = (1 + this.j);
      String str1 = localJSONObject.optString("url");
      String str2 = localJSONObject.optString("checksum");
      e.a().a(str1, str2, paramb, null, paramBundle);
      return;
    }
    a(null);
  }

  public boolean a()
  {
    if (this.h != this.j)
      return false;
    if (this.c != null)
      this.c.a();
    return true;
  }

  public boolean b()
  {
    if (this.g.c != a.b.b)
      return false;
    Chartboost.sharedChartboost().a(this.g);
    Activity localActivity = Chartboost.sharedChartboost().b();
    if (localActivity == null)
    {
      this.k = null;
      return false;
    }
    this.k = a(localActivity);
    if (this.k.a(localActivity))
      return true;
    this.k = null;
    return false;
  }

  public void c()
  {
    e();
    this.c = null;
    this.d = null;
    this.b = null;
    this.a = null;
    this.f = null;
  }

  public b d()
  {
    return this.k;
  }

  public void e()
  {
    if (this.k != null)
      this.k.b();
    this.k = null;
  }

  public static abstract interface a
  {
    public abstract void a();
  }

  public abstract class b extends RelativeLayout
    implements s.a
  {
    protected boolean a = false;

    public b(Context arg2)
    {
      super();
      setFocusableInTouchMode(true);
      requestFocus();
      setOnTouchListener(new View.OnTouchListener()
      {
        public boolean onTouch(View paramAnonymousView, MotionEvent paramAnonymousMotionEvent)
        {
          return true;
        }
      });
    }

    private boolean b(int paramInt1, int paramInt2)
    {
      try
      {
        a(paramInt1, paramInt2);
        return true;
      }
      catch (Exception localException)
      {
      }
      return false;
    }

    public void a()
    {
      a((Activity)getContext());
    }

    protected abstract void a(int paramInt1, int paramInt2);

    public boolean a(Activity paramActivity)
    {
      try
      {
        j = getWidth();
        i = getHeight();
        if ((j == 0) || (i == 0))
        {
          View localView = paramActivity.getWindow().findViewById(16908290);
          if (localView == null)
            localView = paramActivity.getWindow().getDecorView();
          j = localView.getWidth();
          int m = localView.getHeight();
          i = m;
        }
        if ((j == 0) || (i == 0))
        {
          DisplayMetrics localDisplayMetrics = new DisplayMetrics();
          paramActivity.getWindowManager().getDefaultDisplay().getMetrics(localDisplayMetrics);
          j = localDisplayMetrics.widthPixels;
          i = localDisplayMetrics.heightPixels;
        }
        if (Chartboost.sharedChartboost().getForcedOrientationDifference().isOdd())
          return b(i, j);
      }
      catch (Exception localException)
      {
        while (true)
        {
          int i = 0;
          int j = 0;
          continue;
          int k = i;
          i = j;
          j = k;
        }
      }
    }

    public void b()
    {
    }

    protected void onSizeChanged(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
    {
      super.onSizeChanged(paramInt1, paramInt2, paramInt3, paramInt4);
      if (this.a)
        return;
      if (Chartboost.sharedChartboost().getForcedOrientationDifference().isOdd())
      {
        b(paramInt2, paramInt1);
        return;
      }
      b(paramInt1, paramInt2);
    }
  }

  public static abstract interface c
  {
    public abstract void a(String paramString, JSONObject paramJSONObject);
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.chartboost.sdk.b
 * JD-Core Version:    0.6.2
 */